package com.yxplearn.mybatisplus.controller;


import com.yxplearn.mybatisplus.pojo.User;
import com.yxplearn.mybatisplus.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
public class MapperTest {

    @Autowired
    UserService userService;

    @RequestMapping("/autoTest")
    @ResponseBody
    public void autowriedMapperTest() throws Exception {

        List<User> userList = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            User user = new User();
            user.setAge(i);
            user.setName("test" + i);
            userList.add(user);
        }
        userService.saveBatch(userList);
    }
}
